import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios";
import api from "@/global/api";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
		nav:'',
		logo:'',
		footer:'',
		token:''		
  },
  mutations: {
		setHeader (state,{nav,logo}) {
			state.nav = nav;
			state.logo = logo;
		},
		setFooter (state,{footer}) {
			state.footer = footer;		
		},
		setToken(state,token){
			state.token = token;
		}		
  },
  actions: {
		async getHeader({ commit }){
			let {data:logo} = await axios.get(api.getRes,{params:{resName:'logo'}});
			let {data:nav} = await axios.get(api.getNav);
			commit('setHeader', {nav,logo});
		},
		async getFooter({ commit }){
			let {data:footer} = await axios.get(api.getRes,{params:{resName:'footer'}});
			await commit('setFooter', {footer});
		},		
  },
  modules: {
  }
})
